Read the genotype, phenotype and fitness information of evolved populations of 3000 network topology samples.
jointResultsFolder = "20211201_40node_0.05dens_joint_topos"
pathToJointResultsFolder = paste0("../results/", jointResultsFolder)
# read results and split into sel & neutr
allNetsResults_joint <- read.table(paste0(pathToJointResultsFolder, "/allNetsResults_prepped_joint.txt"),
sep = "\t", header = TRUE)
# rename nets
allNetsResults_joint[allNetsResults_joint$topo == "BA", "net"] <-
allNetsResults_joint[allNetsResults_joint$topo == "BA", "net"] + 1000
allNetsResults_joint[allNetsResults_joint$topo == "WS", "net"] <-
allNetsResults_joint[allNetsResults_joint$topo == "WS", "net"] + 2000
allNetsResults_joint$topo <- factor(allNetsResults_joint$topo, levels = c("ER", "BA", "WS"))
# remove genes of degree 1 because they make in and outlink metrics colinear
# reason: when we generate networks we impose that the network must have a single component
# i.e. all genes are connected. Many genes end up having just one connection, which can be either
# an in or outlink.
allNetsResults_joint <- allNetsResults_joint[allNetsResults_joint$absInStr != 0, ]
allNetsResults_joint <- allNetsResults_joint[allNetsResults_joint$absOutStr != 0, ]
selResults <- allNetsResults_joint[allNetsResults_joint$scen == "sel", ]
neutrResults <- allNetsResults_joint[allNetsResults_joint$scen == "neu", ]
# subset responded genes
respondedToSelCutoff <- 0.5
# add which genes responded to selection
selResults$responseToSel <- selResults$s_g_area_abs > respondedToSelCutoff
# subset the genes that responded to selection
respondedGenes <- selResults[selResults$responseToSel == TRUE, ]
library(nlme)
library(MuMIn) # for r.squared in lme models
library(ggplot2)
library(ggpubr) # for the pubclean theme
library(ggridges)
library(gridExtra)
library(cowplot) # for arranging plots
##
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
##
## get_legend
library(infotheo)
library(lme4)
## Loading required package: Matrix
##
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
##
## lmList
library(car) # for vif measure
## Loading required package: carData
library(RColorBrewer) # for color palettes
library(latex2exp) # for latex notation in the plots
library(reshape2)
library("Hmisc") # for correlation matrix
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
library(corrplot) # for plotting correlation matrix
## corrplot 0.90 loaded
library(ade4) # for PCA
library(factoextra) # for scree plot
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(FSA) # for Dunn tests
## Registered S3 methods overwritten by 'FSA':
## method from
## confint.boot car
## hist.boot car
## ## FSA v0.9.3. See citation('FSA') if used in publication.
## ## Run fishR() for related website and fishR('IFAR') for related book.
##
## Attaching package: 'FSA'
## The following object is masked from 'package:car':
##
## bootCase
library(rstatix) # for partial eta for lms
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(dplyr) # for summarizing dataframes
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:Hmisc':
##
## src, summarize
## The following object is masked from 'package:car':
##
## recode
## The following object is masked from 'package:gridExtra':
##
## combine
## The following object is masked from 'package:nlme':
##
## collapse
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# MI
calcInformation <- function (v1, v2, binNum) {
# discretize
d_v1 <- discretize(v1, nbins = binNum);
d_v2 <- discretize(v2, nbins = binNum)
# mutual information
I_v1v2 <- mutinformation(d_v1, d_v2);
return("MI" = I_v1v2)
}
# colors for plots
noiseColor = "#01665e"
genotypeColor = "#7b3294"
phenotypeColor = "#d95f0e"
fitnessColor = "#e78ac3"
neutralityColor = "darkgray"
MIColor = "#2c7fb8"
topoColors = c("ER" = "darkgray", "BA" = "#c51b7d", "WS" = "#4d9221")
netAllResults <- allNetsResults_joint %>%
group_by(scen, net) %>%
summarize(ave_varP_1 = mean(varP_1),
ave_varP_10000 = mean(varP_10000),
ave_relDeltaVar_10000 = mean(relDeltaVar_10000),
ave_s_g_area_abs = mean(s_g_area_abs),
topo = first(topo))
## `summarise()` has grouped output by 'scen'. You can override using the `.groups` argument.
netSelResults <- selResults %>%
group_by(scen, net) %>%
summarize(ave_varP_1 = mean(varP_1),
ave_varP_10000 = mean(varP_10000),
ave_relDeltaVar_10000 = mean(relDeltaVar_10000),
ave_s_g_area_abs = mean(s_g_area_abs),
ave_responseToSel = length(which(responseToSel)),
topo = first(topo))
## `summarise()` has grouped output by 'scen'. You can override using the `.groups` argument.
evolMetricsColnames <- c("meanG_1", "meanG_10000",
"meanP_1", "meanP_10000",
"varP_1", "varP_10000",
"CVP_1", "CVP_10000",
"noiseP_1", "noiseP_10000",
"FanoP_1", "FanoP_10000",
"relDeltaVar_1", "relDeltaVar_10000",
"relDeltaCV_1", "relDeltaCV_10000",
"relDeltaNoise_1", "relDeltaNoise_10000",
"relDeltaFano_1", "relDeltaFano_10000",
"s_g_area", "s_g_area_abs",
"s_p_area_relDeltaVar", "s_p_area_relDeltaCV",
"s_p_area_relDeltaNoise", "s_p_area_relDeltaFano")
evolMetricsColnames_ofInterest <- c("varP_1", "relDeltaVar_10000", "s_g_area_abs")
geneSpecificNetMetricsColnames <- c("k_all_inclps", "k_in_inclps", "k_out_inclps",
"clo_all", "betw", "eigen_centr",
"str_all_inclps", "str_in_inclps", "str_out_inclps",
"hub_score", "auth_incwght", "auth_excwght",
"absstr_all_inclps", "absInStr", "absOutStr",
"flow", "load", "info", "stress",
"absInStrT_sqrt", "absOutStrT_sqrt",
"absInStrT_log1p", "absOutStrT_log1p",
"absInStrT_log10", "absOutStrT_log10")
geneSpecificNetMetricsColnames_ofInterest <- c("k_all_inclps", "k_in_inclps", "k_out_inclps",
"clo_all", "betw", "eigen_centr",
"str_all_inclps", "str_in_inclps", "str_out_inclps",
"hub_score", "auth_incwght", "auth_excwght",
"absstr_all_inclps", "absInStr", "absOutStr",
"flow", "load", "info", "stress")
globalNetMetricsColnames <- c("diam", "meandst", "assort",
"cntr_degr_all", "cntr_indegr", "cntr_outdegr", "cntr_clo_all", "cntr_betw",
"ave_k_all_inclps", "ave_k_in_inclps","ave_k_out_inclps")
singletsSelResults <- selResults[!duplicated(selResults$net), c("net", globalNetMetricsColnames)]
netSelResults <- merge(netSelResults, singletsSelResults, by = "net")
singletsAllResults <- allNetsResults_joint[!duplicated(allNetsResults_joint$net), c("net", globalNetMetricsColnames)]
netAllResults <- merge(netAllResults, singletsAllResults, by = "net")
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = varP_1, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Expr. variance, gen 1")))
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = varP_10000, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
ylab(expression(bold("Expr. variance, gen 10k"))) +
xlab("Network topology")
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = relDeltaVar_10000, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
ylab(expression(bold("Rel."~Delta~"expr. variance"))) +
xlab("Network topology")
## Warning: Removed 130 rows containing non-finite values (stat_boxplot).
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = s_g_area_abs, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = genotypeColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = genotypeColor, "neutr" = genotypeColor)) +
ylab(expression(paste(bold("Selective pressure "), "|", bold(p), "|"))) +
xlab("Network topology")
my_comparisons <- list( c("ER", "BA"), c("BA", "WS"), c("WS", "ER") )
# just selection
plot_varFirstgen_sel <- ggplot(selResults, aes(y = varP_1, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.05, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label=round(..y.., digits=2))) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = "Expr. variance, gen 1",
fill = "Topology")
plot_varFirstgen_sel
ggsave(filename = sprintf("plot_varFirstgen_sel.png"),
plot = plot_varFirstgen_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
# just selection
plot_varLastgen_sel <- ggplot(selResults, aes(y = varP_10000, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.05, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label=round(..y.., digits=2))) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = "Expr. variance, gen 10k",
fill = "Topology")
plot_varLastgen_sel
ggsave(filename = sprintf("plot_varLastgen_sel.png"),
plot = plot_varLastgen_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
# just selection
plot_relDeltaVar_sel <- ggplot(selResults, aes(y = relDeltaVar_10000, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = expression(bold("Rel."~Delta~"expr. variance")),
fill = "Topology")
plot_relDeltaVar_sel
## Warning: Removed 90 rows containing non-finite values (stat_ydensity).
## Warning: Removed 90 rows containing non-finite values (stat_boxplot).
## Warning: Removed 90 rows containing non-finite values (stat_summary).
## Warning: Removed 90 rows containing non-finite values (stat_signif).
ggsave(filename = sprintf("plot_relDeltaVar_sel.png"),
plot = plot_relDeltaVar_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
## Warning: Removed 90 rows containing non-finite values (stat_ydensity).
## Warning: Removed 90 rows containing non-finite values (stat_boxplot).
## Warning: Removed 90 rows containing non-finite values (stat_summary).
## Warning: Removed 90 rows containing non-finite values (stat_signif).
# just selection
plot_selpress_sel <- ggplot(selResults, aes(y = s_g_area_abs, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = 3, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = expression(paste(bold("Selective pressure "), "|", bold(p), "|")),
fill = "Topology")
plot_selpress_sel
ggsave(filename = sprintf("plot_selpress_sel.png"),
plot = plot_selpress_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
plot_violin_metrics_per_topo <- plot_grid(plot_varFirstgen_sel,
plot_varLastgen_sel,
plot_relDeltaVar_sel,
plot_selpress_sel,
scale = c(0.95, 0.95, 0.95, 0.95),
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning: Removed 90 rows containing non-finite values (stat_ydensity).
## Warning: Removed 90 rows containing non-finite values (stat_boxplot).
## Warning: Removed 90 rows containing non-finite values (stat_summary).
## Warning: Removed 90 rows containing non-finite values (stat_signif).
ggsave(filename = sprintf("plot_violin_metrics_per_topo.png"),
plot = plot_violin_metrics_per_topo,
bg = "white",
path = pathToPlotsFolder,
device = "png", scale = 1.8, width = 17, height = 12, units = "cm",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_violin_metrics_per_topo.tiff"),
plot = plot_violin_metrics_per_topo,
bg = "white",
path = pathToPlotsFolder,
device = "tiff", scale = 1.8, width = 17, height = 12, units = "cm",
dpi = 300, limitsize = TRUE)
summary(selResults$varP_1[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1648 139.0104 282.1687 338.6733 458.7734 2166.1780
summary(selResults$varP_1[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0001 131.4944 231.0748 353.3577 429.9174 2397.0850
summary(selResults$varP_1[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0001 130.1976 240.8380 395.2082 509.2964 2326.2150
summary(selResults$varP_10000[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 3.953 8.371 9.901 12.792 459.084
summary(selResults$varP_10000[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 4.644 8.832 22.482 16.325 2425.164
summary(selResults$varP_10000[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 3.777 8.387 24.483 18.735 2130.139
summary(selResults$relDeltaVar_10000[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.00000 -0.96262 -0.94869 -0.94439 -0.93212 0.01953 4
summary(selResults$relDeltaVar_10000[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.0000 -0.9508 -0.9288 -0.9123 -0.9004 1.0000 33
summary(selResults$relDeltaVar_10000[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.0000 -0.9576 -0.9347 -0.9163 -0.9046 0.5278 53
summary(selResults$s_g_area_abs[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000025 0.8600859 0.8966813 0.8057883 0.9308498 0.9855338
summary(selResults$s_g_area_abs[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00001 0.82738 0.88613 0.77038 0.92574 0.98224
summary(selResults$s_g_area_abs[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000021 0.7913765 0.8913866 0.7449805 0.9337625 0.9836893
kruskal.test(varP_1 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: varP_1 by topo
## Kruskal-Wallis chi-squared = 69.922, df = 2, p-value = 6.555e-16
kruskal.test(varP_10000 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: varP_10000 by topo
## Kruskal-Wallis chi-squared = 255.8, df = 2, p-value < 2.2e-16
kruskal.test(relDeltaVar_10000 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: relDeltaVar_10000 by topo
## Kruskal-Wallis chi-squared = 2830.3, df = 2, p-value < 2.2e-16
kruskal.test(s_g_area_abs ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: s_g_area_abs by topo
## Kruskal-Wallis chi-squared = 296.08, df = 2, p-value < 2.2e-16
pairwise.wilcox.test(selResults$varP_1, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$varP_1 and selResults$topo
##
## ER BA
## BA 1.8e-14 -
## WS 6.8e-11 0.11
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$varP_10000, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$varP_10000 and selResults$topo
##
## ER BA
## BA < 2e-16 -
## WS 6.1e-05 < 2e-16
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$relDeltaVar_10000, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$relDeltaVar_10000 and selResults$topo
##
## ER BA
## BA <2e-16 -
## WS <2e-16 <2e-16
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$s_g_area_abs, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$s_g_area_abs and selResults$topo
##
## ER BA
## BA < 2e-16 -
## WS 9.4e-07 < 2e-16
##
## P value adjustment method: BH
# ER to BA
wilcox.test(selResults$varP_1[selResults$topo == "ER"], selResults$varP_1[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "ER"] and selResults$varP_1[selResults$topo == "BA"]
## W = 146955679, p-value = 3.081e-15
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "ER"], selResults$varP_1[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "ER"] and selResults$varP_1[selResults$topo == "BA"]
## W = 146955679, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$varP_1[selResults$topo == "BA"], selResults$varP_1[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "BA"] and selResults$varP_1[selResults$topo == "WS"]
## W = 196526721, p-value = 0.9456
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "BA"], selResults$varP_1[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "BA"] and selResults$varP_1[selResults$topo == "WS"]
## W = 196526721, p-value = 0.05441
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$varP_1[selResults$topo == "WS"], selResults$varP_1[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "WS"] and selResults$varP_1[selResults$topo == "ER"]
## W = 457296947, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "WS"], selResults$varP_1[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "WS"] and selResults$varP_1[selResults$topo == "ER"]
## W = 457296947, p-value = 2.271e-11
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$varP_10000[selResults$topo == "ER"], selResults$varP_10000[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "ER"] and selResults$varP_10000[selResults$topo == "BA"]
## W = 170461586, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "ER"], selResults$varP_10000[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "ER"] and selResults$varP_10000[selResults$topo == "BA"]
## W = 170461586, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$varP_10000[selResults$topo == "BA"], selResults$varP_10000[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "BA"] and selResults$varP_10000[selResults$topo == "WS"]
## W = 178769580, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "BA"], selResults$varP_10000[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "BA"] and selResults$varP_10000[selResults$topo == "WS"]
## W = 178769580, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$varP_10000[selResults$topo == "WS"], selResults$varP_10000[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "WS"] and selResults$varP_10000[selResults$topo == "ER"]
## W = 434993181, p-value = 3.03e-05
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "WS"], selResults$varP_10000[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "WS"] and selResults$varP_10000[selResults$topo == "ER"]
## W = 434993181, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "ER"], selResults$relDeltaVar_10000[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "ER"] and selResults$relDeltaVar_10000[selResults$topo == "BA"]
## W = 208663610, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "ER"], selResults$relDeltaVar_10000[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "ER"] and selResults$relDeltaVar_10000[selResults$topo == "BA"]
## W = 208663610, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "BA"], selResults$relDeltaVar_10000[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "BA"] and selResults$relDeltaVar_10000[selResults$topo == "WS"]
## W = 145879932, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "BA"], selResults$relDeltaVar_10000[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "BA"] and selResults$relDeltaVar_10000[selResults$topo == "WS"]
## W = 145879932, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "WS"], selResults$relDeltaVar_10000[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "WS"] and selResults$relDeltaVar_10000[selResults$topo == "ER"]
## W = 407500592, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "WS"], selResults$relDeltaVar_10000[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "WS"] and selResults$relDeltaVar_10000[selResults$topo == "ER"]
## W = 407500592, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$s_g_area_abs[selResults$topo == "ER"], selResults$s_g_area_abs[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "ER"] and selResults$s_g_area_abs[selResults$topo == "BA"]
## W = 137097094, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "ER"], selResults$s_g_area_abs[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "ER"] and selResults$s_g_area_abs[selResults$topo == "BA"]
## W = 137097094, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$s_g_area_abs[selResults$topo == "BA"], selResults$s_g_area_abs[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "BA"] and selResults$s_g_area_abs[selResults$topo == "WS"]
## W = 210471566, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "BA"], selResults$s_g_area_abs[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "BA"] and selResults$s_g_area_abs[selResults$topo == "WS"]
## W = 210471566, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$s_g_area_abs[selResults$topo == "WS"], selResults$s_g_area_abs[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "WS"] and selResults$s_g_area_abs[selResults$topo == "ER"]
## W = 453756137, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "WS"], selResults$s_g_area_abs[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "WS"] and selResults$s_g_area_abs[selResults$topo == "ER"]
## W = 453756137, p-value = 4.716e-07
## alternative hypothesis: true location shift is greater than 0
dunnTest(varP_1 ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER 7.158985 8.127635e-13 2.438290e-12
## 2 BA - WS 2.130387 3.313972e-02 3.313972e-02
## 3 ER - WS -6.887795 5.666368e-12 8.499552e-12
dunnTest(varP_10000 ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER -15.76887 5.095664e-56 1.528699e-55
## 2 BA - WS -13.18042 1.137614e-39 1.706421e-39
## 3 ER - WS 4.06425 4.818725e-05 4.818725e-05
dunnTest(relDeltaVar_10000 ~ topo, data = selResults, method = "bh")
## Warning: Some rows deleted from 'x' and 'g' because missing data.
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER -52.96934 0.000000e+00 0.000000e+00
## 2 BA - WS -41.46320 0.000000e+00 0.000000e+00
## 3 ER - WS 17.32305 3.152052e-67 3.152052e-67
dunnTest(s_g_area_abs ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER 17.088478 1.808336e-65 5.425007e-65
## 2 BA - WS 13.669766 1.538893e-42 2.308339e-42
## 3 ER - WS -5.207388 1.915178e-07 1.915178e-07
lmeModel <- lm(ave_varP_1 ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_varP_1 ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -262.26 -78.16 -15.13 63.70 606.50
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 352.694 3.499 100.807 < 2e-16 ***
## topoBA -18.333 4.948 -3.705 0.000215 ***
## topoWS 40.416 4.948 8.168 4.56e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 110.6 on 2997 degrees of freedom
## Multiple R-squared: 0.04694, Adjusted R-squared: 0.04631
## F-statistic: 73.81 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.
## R2m R2c
## [1,] 0.04691374 0.04691374
lmeModel <- lm(ave_varP_10000 ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_varP_10000 ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.85 -10.07 -3.59 0.21 861.43
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 22.106 1.094 20.210 < 2e-16 ***
## topoBA -12.401 1.547 -8.017 1.54e-15 ***
## topoWS 2.027 1.547 1.310 0.19
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 34.59 on 2997 degrees of freedom
## Multiple R-squared: 0.03291, Adjusted R-squared: 0.03227
## F-statistic: 51 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.03288984 0.03288984
lmeModel <- lm(ave_relDeltaVar_10000 ~ topo,
data = netSelResults[!is.na(netSelResults$ave_relDeltaVar_10000), ])
summary(lmeModel)
##
## Call:
## lm(formula = ave_relDeltaVar_10000 ~ topo, data = netSelResults[!is.na(netSelResults$ave_relDeltaVar_10000),
## ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.03860 -0.01424 -0.00628 0.00266 0.63702
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.912812 0.001304 -700.007 <2e-16 ***
## topoBA -0.032025 0.001832 -17.485 <2e-16 ***
## topoWS -0.004418 0.001854 -2.382 0.0173 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04059 on 2910 degrees of freedom
## Multiple R-squared: 0.1101, Adjusted R-squared: 0.1095
## F-statistic: 179.9 on 2 and 2910 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.1099949 0.1099949
lmeModel <- lm(ave_s_g_area_abs ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.67253 -0.03775 0.01170 0.04729 0.13888
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.770923 0.002406 320.368 < 2e-16 ***
## topoBA 0.033993 0.003403 9.989 < 2e-16 ***
## topoWS -0.025315 0.003403 -7.439 1.32e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0761 on 2997 degrees of freedom
## Multiple R-squared: 0.09261, Adjusted R-squared: 0.09201
## F-statistic: 152.9 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.09255582 0.09255582
logRegModel <- glmer(responseToSel ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo + (1|net),
data = selResults,
family = binomial,
control = glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
summary(logRegModel)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: responseToSel ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo + (1 |
## net)
## Data: selResults
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
##
## AIC BIC logLik deviance df.resid
## 50728.0 50819.8 -25354.0 50708.0 71595
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -9.5125 0.1713 0.2554 0.3982 3.7128
##
## Random effects:
## Groups Name Variance Std.Dev.
## net (Intercept) 0.1398 0.3739
## Number of obs: 71605, groups: net, 3000
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 5.086008 0.077100 65.967 < 2e-16 ***
## absInStrT_sqrt -1.802274 0.031955 -56.400 < 2e-16 ***
## absOutStrT_sqrt -0.236429 0.029744 -7.949 1.88e-15 ***
## topoBA 1.690235 0.174331 9.696 < 2e-16 ***
## topoWS -0.265964 0.104774 -2.538 0.011135 *
## absInStrT_sqrt:topoBA -0.314604 0.081584 -3.856 0.000115 ***
## absInStrT_sqrt:topoWS -0.066180 0.043605 -1.518 0.129082
## absOutStrT_sqrt:topoBA -0.259738 0.033749 -7.696 1.40e-14 ***
## absOutStrT_sqrt:topoWS 0.009153 0.040944 0.224 0.823116
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W aOST_:B
## absInStrT_s -0.775
## absOtStrT_s -0.591 0.048
## topoBA -0.432 0.334 0.262
## topoWS -0.726 0.563 0.435 0.320
## absInST_:BA 0.297 -0.386 -0.019 -0.911 -0.219
## absInST_:WS 0.559 -0.725 -0.035 -0.247 -0.776 0.284
## absOtST_:BA 0.517 -0.038 -0.881 -0.468 -0.383 0.164 0.030
## absOtST_:WS 0.430 -0.035 -0.726 -0.190 -0.624 0.013 0.086 0.640
lmeModel <- lme(varP_1 ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = selResults,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: selResults
## AIC BIC logLik
## 988557.4 988667.6 -494266.7
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 41.17568 55.01751
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 1.036034
## Fixed effects: varP_1 ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) 48.15409 3.826547 68599 12.58422 0.0000
## absInStrT_sqrt 230.94334 2.646290 68599 87.27061 0.0000
## absOutStrT_sqrt -21.63507 1.644374 68599 -13.15703 0.0000
## topoBA 26.91664 8.073025 2997 3.33415 0.0009
## topoWS -33.41109 5.581999 2997 -5.98551 0.0000
## absInStrT_sqrt:topoBA -37.01439 5.502201 68599 -6.72720 0.0000
## absInStrT_sqrt:topoWS 51.96763 3.595365 68599 14.45406 0.0000
## absOutStrT_sqrt:topoBA -3.16029 1.971353 68599 -1.60311 0.1089
## absOutStrT_sqrt:topoWS 3.18058 2.415215 68599 1.31689 0.1879
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.658
## absOutStrT_sqrt -0.683 0.110
## topoBA -0.474 0.312 0.324
## topoWS -0.686 0.451 0.468 0.325
## absInStrT_sqrt:topoBA 0.316 -0.481 -0.053 -0.829 -0.217
## absInStrT_sqrt:topoWS 0.484 -0.736 -0.081 -0.230 -0.650 0.354
## absOutStrT_sqrt:topoBA 0.570 -0.091 -0.834 -0.582 -0.391 0.224 0.067
## absOutStrT_sqrt:topoWS 0.465 -0.075 -0.681 -0.220 -0.715 0.036 0.130
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.568
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -3.0554341 -0.6144405 -0.1431631 0.4085847 7.7066634
##
## Number of Observations: 71605
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.8292969 0.8905832
lmeModel <- lme(relDeltaVar_10000 ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -178667.6 -178559.5 89345.8
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.02577517 0.03457918
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 0.3238401
## Fixed effects: relDeltaVar_10000 ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) -0.8920085 0.0014150225 57540 -630.3846 0.0000
## absInStrT_sqrt 0.0041702 0.0006828856 57540 6.1068 0.0000
## absOutStrT_sqrt -0.0175873 0.0005458196 57540 -32.2219 0.0000
## topoBA -0.0130093 0.0026880429 2997 -4.8397 0.0000
## topoWS -0.0100136 0.0020553971 2997 -4.8719 0.0000
## absInStrT_sqrt:topoBA -0.0173448 0.0014474836 57540 -11.9828 0.0000
## absInStrT_sqrt:topoWS 0.0047507 0.0009483660 57540 5.0094 0.0000
## absOutStrT_sqrt:topoBA 0.0078031 0.0006505324 57540 11.9949 0.0000
## absOutStrT_sqrt:topoWS -0.0007539 0.0007937504 57540 -0.9498 0.3422
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.565
## absOutStrT_sqrt -0.579 0.071
## topoBA -0.526 0.297 0.305
## topoWS -0.688 0.389 0.399 0.362
## absInStrT_sqrt:topoBA 0.267 -0.472 -0.034 -0.785 -0.183
## absInStrT_sqrt:topoWS 0.407 -0.720 -0.051 -0.214 -0.574 0.340
## absOutStrT_sqrt:topoBA 0.486 -0.060 -0.839 -0.514 -0.334 0.196 0.043
## absOutStrT_sqrt:topoWS 0.398 -0.049 -0.688 -0.210 -0.613 0.023 0.111
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.577
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -7.1611542 -0.4561679 -0.1423956 0.2539409 24.3732650
##
## Number of Observations: 60546
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.1224098 0.4358563
lmeModel <- lme(s_g_area_abs ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -168395.4 -168287.3 84209.71
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.01400798 0.03051506
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 0.5003005
## Fixed effects: s_g_area_abs ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) 0.8948130 0.0013090910 57540 683.5377 0e+00
## absInStrT_sqrt -0.0394919 0.0007829890 57540 -50.4373 0e+00
## absOutStrT_sqrt 0.0292661 0.0005762394 57540 50.7881 0e+00
## topoBA 0.0224292 0.0026763460 2997 8.3805 0e+00
## topoWS 0.0141659 0.0019184405 2997 7.3841 0e+00
## absInStrT_sqrt:topoBA 0.0139373 0.0016258567 57540 8.5723 0e+00
## absInStrT_sqrt:topoWS -0.0054309 0.0010813112 57540 -5.0225 0e+00
## absOutStrT_sqrt:topoBA -0.0171635 0.0006879068 57540 -24.9504 0e+00
## absOutStrT_sqrt:topoWS -0.0028399 0.0008415108 57540 -3.3748 7e-04
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.654
## absOutStrT_sqrt -0.670 0.082
## topoBA -0.489 0.320 0.328
## topoWS -0.682 0.446 0.457 0.334
## absInStrT_sqrt:topoBA 0.315 -0.482 -0.039 -0.841 -0.215
## absInStrT_sqrt:topoWS 0.474 -0.724 -0.059 -0.232 -0.655 0.349
## absOutStrT_sqrt:topoBA 0.561 -0.068 -0.838 -0.564 -0.383 0.211 0.050
## absOutStrT_sqrt:topoWS 0.459 -0.056 -0.685 -0.224 -0.703 0.027 0.117
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.574
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -8.8776585 -0.3479205 0.2051624 0.6193280 2.5547659
##
## Number of Observations: 60546
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.4347666 0.5331459
lmeModel <- lme(s_g_area_abs ~ absInStrT_sqrt + absOutStrT_sqrt + topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -167224.2 -167152.1 83620.09
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.01390728 0.03089286
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 0.4987068
## Fixed effects: s_g_area_abs ~ absInStrT_sqrt + absOutStrT_sqrt + topo
## Value Std.Error DF t-value p-value
## (Intercept) 0.9114564 0.0008996411 57544 1013.1333 0
## absInStrT_sqrt -0.0400760 0.0005095330 57544 -78.6524 0
## absOutStrT_sqrt 0.0178831 0.0002745940 57544 65.1256 0
## topoBA 0.0129268 0.0009730976 2997 13.2842 0
## topoWS 0.0050655 0.0007950180 2997 6.3716 0
## Correlation:
## (Intr) abIST_ abOST_ topoBA
## absInStrT_sqrt -0.647
## absOutStrT_sqrt -0.531 0.176
## topoBA -0.194 -0.170 -0.186
## topoWS -0.422 -0.034 -0.030 0.429
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -8.7352837 -0.3681114 0.2126254 0.6257409 2.5669098
##
## Number of Observations: 60546
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.406898 0.5068415
# subset
ave_evolMetricsColnames_ofInterest <- c("ave_varP_1", "ave_relDeltaVar_10000", "ave_s_g_area_abs")
# There are also "num_generations", "num_nodes", "dens", "pop_size" columns, but they are identical for all topos.
# global net metrics
globalMetrics_forCorrs_sel <- netSelResults[, c(ave_evolMetricsColnames_ofInterest, globalNetMetricsColnames)]
globalMetrics_forCorrs_neu <- netSelResults[, c(ave_evolMetricsColnames_ofInterest, globalNetMetricsColnames)]
# gene-specific metrics
geneMetrics_forCorrs_sel <- selResults[, c(evolMetricsColnames_ofInterest, geneSpecificNetMetricsColnames_ofInterest)]
geneMetrics_forCorrs_neu <- neutrResults[, c(evolMetricsColnames_ofInterest, geneSpecificNetMetricsColnames_ofInterest)]
# selection
geneSpecificCorrs_sel <- rcorr(as.matrix(geneMetrics_forCorrs_sel), type = "spearman")
# neutrality
geneSpecificCorrs_neu <- rcorr(as.matrix(geneMetrics_forCorrs_neu), type = "spearman")
png(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_sel.png"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_sel.tiff"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
png(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_neu.png"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_neu.tiff"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
# selection
globalCorrs_sel <- rcorr(as.matrix(globalMetrics_forCorrs_sel), type = "spearman")
# neutrality
globalCorrs_neu <- rcorr(as.matrix(globalMetrics_forCorrs_neu), type = "spearman")
png(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_sel.png"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_sel.tiff"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
png(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_neu.png"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_neu.tiff"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
globalMetrics_forPCA <- netAllResults[, globalNetMetricsColnames]
colnames(globalMetrics_forPCA) <- c("diameter", "mean path distance", "degree assortativity", "degree centralization",
"indegree centralization", "outdegree centralization", "closeness centralization",
"betweenness centralization", "average degree", "average indegree", "average outdegree")
dudi <- dudi.pca(globalMetrics_forPCA, center = TRUE, scale = TRUE, nf = 10, scannf = FALSE)
plot_biplot <- fviz_pca_biplot(dudi,
geom.ind = "point",
col.ind = netAllResults$topo,
col.var = "black",
repel = TRUE,
addEllipses = TRUE,
legend.title = "Topology") +
scale_colour_manual(values = topoColors)
plot_biplot
plot_scree <- fviz_eig(dudi, addlabels = TRUE)
plot_corCircle <- fviz_pca_var(dudi, col.var = "contrib", labelsize = 4, repel = TRUE) +
scale_color_gradient2(low = "white", mid = "blue", high = "black")
plot_PCA <- plot_grid(plot_scree, plot_corCircle,
scale = c(0.95, 0.95),
labels = "AUTO",
label_size = 20,
label_fontface = "bold",
ncol = 2)
ggsave(filename = sprintf("plot_PCA.png"),
plot = plot_PCA,
path = pathToPlotsFolder, bg = 'white',
device = "png", scale = 2, width = 18, height = 9, units = "cm",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_PCA.tiff"),
plot = plot_PCA,
path = pathToPlotsFolder, bg = 'white',
device = "tiff", scale = 2, width = 18, height = 9, units = "cm",
dpi = 300, limitsize = TRUE)
netAllResults$PC1<- -dudi$li$Axis1
netAllResults$PC2<- -dudi$li$Axis2
ave_responseToSel <- netSelResults$ave_responseToSel
netSelResults <- netAllResults[netAllResults$scen == "sel", ]
netSelResults$ave_responseToSel <- ave_responseToSel
netNeuResults <- netAllResults[netAllResults$scen == "neu", ]
# just selection
plot_PC1_topos <- ggplot(netSelResults, aes(y = PC1, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("PC1 (diameter + centralization)")))
plot_PC1_topos
plot_PC2_topos <- ggplot(netSelResults, aes(y = PC2, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("PC2 (average degree)")))
plot_PC2_topos
plot_netMetric <- ggplot(netSelResults, aes(y = diam, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Diameter")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = cntr_indegr, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Indegree centralization")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = cntr_outdegr, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Outdegree centralization")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_all_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average degree")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_in_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average indegree")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_out_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average outdegree")))
plot_netMetric
lmModel <- lm(ave_responseToSel ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_responseToSel ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.0155 -1.8104 0.1247 2.0208 8.8685
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 20.18200 0.05508 366.39 <2e-16 ***
## PC1 2.56846 0.02213 116.08 <2e-16 ***
## PC2 1.83067 0.03077 59.49 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.017 on 2997 degrees of freedom
## Multiple R-squared: 0.8502, Adjusted R-squared: 0.8501
## F-statistic: 8506 on 2 and 2997 DF, p-value: < 2.2e-16
plot_PC1 <- ggplot(netSelResults, aes(y = ave_responseToSel, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average # responded genes"))))
plot_PC1
plot_PC2 <- ggplot(netSelResults, aes(y = ave_responseToSel, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average # responded genes"))))
plot_PC2
# just selection
numResponded <- table(selResults$topo, selResults$responseToSel)
numResponded
##
## FALSE TRUE
## ER 3778 22775
## BA 1342 10310
## WS 5939 27461
numTopos <- as.vector(table(selResults$topo))
numResponded[, 2]/numTopos
## ER BA WS
## 0.8577185 0.8848266 0.8221856
#plot_numRespondedGenes <- ggplot(respondedGenes, aes(y = , x = topo)) +
# geom_violin(fill = genotypeColor, color = "black", trim = TRUE) +
# geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
# stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
# hjust = 1.25, vjust = 3, color = "black", aes(label = round(..y.., digits = 3))) +
# stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
# theme_pubclean() +
# theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
# axis.title.x = element_text(size=16, face="bold"),
# axis.title.y = element_text(size=16, face="bold"),
# axis.text.x = element_text(size=10, face="bold"),
# axis.text.y = element_text(size=10, face="bold")) +
# scale_fill_manual(values = c("sel" = genotypeColor, "neutr" = genotypeColor)) +
# labs(x = "Network topology",
# y = expression(paste(bold("Selective pressure "), "|", bold(p), "|")))
#plot_numRespondedGenes
#ggsave(filename = sprintf("plot_numRespondedGenes.png"),
# plot = plot_numRespondedGenes,
# device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
# dpi = 300, limitsize = TRUE)
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_varP_1,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_varP_1,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_varP_1,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_varP_1,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_ave_varP_1-PCs.txt"))
cat(paste0("Variables: ave_varP_1; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_varP_1; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_varP_1; PC1
## Observed MI: 0.170000421535257; pval: 0.0133
## Variables: ave_varP_1; PC2
## Observed MI: 0.185751175769187; pval: 1e-04
sink()
lmModel <- lm(ave_varP_1 ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_varP_1 ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -264.44 -78.32 -16.41 64.70 612.82
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 360.055 2.016 178.564 < 2e-16 ***
## PC1 5.827 0.810 7.194 7.92e-13 ***
## PC2 11.655 1.127 10.346 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 110.4 on 2997 degrees of freedom
## Multiple R-squared: 0.05032, Adjusted R-squared: 0.04969
## F-statistic: 79.4 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.05028804 0.05028804
# partial R^2
library(rstatix)
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 3)
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_PC1 <- ggplot(netSelResults, aes(y = ave_varP_1, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Expression variance, gen. 1"))),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 750, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC1
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2 <- ggplot(netSelResults, aes(y = ave_varP_1, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Expression variance, gen. 1"))),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 750, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC2
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_netPropertiesFigure <- plot_grid(plot_PC1, plot_PC2,
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
ggsave(filename = sprintf("plot_netPropertiesFigure_averageExprVar.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure_averageExprVar.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_relDeltaVar_10000,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_relDeltaVar_10000,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_relDeltaVar_10000,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_relDeltaVar_10000,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_ave_relDeltaVar_10000-PCs.txt"))
cat(paste0("Variables: ave_relDeltaVar_10000; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_relDeltaVar_10000; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_relDeltaVar_10000; PC1
## Observed MI: 0.485011441031824; pval: 1e-04
## Variables: ave_relDeltaVar_10000; PC2
## Observed MI: 0.407655804932965; pval: 1e-04
sink()
lmModel <- lm(ave_relDeltaVar_10000 ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_relDeltaVar_10000 ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.03901 -0.01456 -0.00632 0.00263 0.63883
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.9249655 0.0007533 -1227.954 <2e-16 ***
## PC1 0.0056199 0.0003006 18.698 <2e-16 ***
## PC2 0.0005069 0.0004233 1.198 0.231
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04065 on 2910 degrees of freedom
## (87 observations deleted due to missingness)
## Multiple R-squared: 0.1077, Adjusted R-squared: 0.107
## F-statistic: 175.5 on 2 and 2910 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.1075944 0.1075944
# partial R^2
library(rstatix)
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 3)
#if(coef_explVar2 == -0.0096){coef_explVar2 = -0.009}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_PC1 <- ggplot(netSelResults, aes(y = ave_relDeltaVar_10000, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(bold("Rel."~Delta~"expr. variance")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = -0.4, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC1
## Warning: Removed 87 rows containing missing values (geom_point).
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2 <- ggplot(netSelResults, aes(y = ave_relDeltaVar_10000, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(bold("Rel."~Delta~"expr. variance")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = -0.4, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC2
## Warning: Removed 87 rows containing missing values (geom_point).
## Warning: is.na() applied to non-(list or vector) of type 'expression'
plot_netPropertiesFigure <- plot_grid(plot_PC1, plot_PC2,
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning: Removed 87 rows containing missing values (geom_point).
## Warning: is.na() applied to non-(list or vector) of type 'expression'
## Warning: Removed 87 rows containing missing values (geom_point).
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
ggsave(filename = sprintf("plot_netPropertiesFigure_averageRelDeltaVar.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure_averageRelDeltaVar.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
lmeModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.68193 -0.03798 0.01123 0.04778 0.14524
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7738156 0.0013968 554.01 <2e-16 ***
## PC1 -0.0074498 0.0005611 -13.28 <2e-16 ***
## PC2 -0.0075850 0.0007804 -9.72 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0765 on 2997 degrees of freedom
## Multiple R-squared: 0.08286, Adjusted R-squared: 0.08225
## F-statistic: 135.4 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.08280831 0.08280831
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netNeuResults$ave_s_g_area_abs,
netNeuResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netNeuResults$ave_s_g_area_abs,
netNeuResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netNeuResults$ave_s_g_area_abs,
sample(netNeuResults$PC1,
size = length(netNeuResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netNeuResults$ave_s_g_area_abs,
sample(netNeuResults$PC2,
size = length(netNeuResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_s_g_area_abs-PCs_neutrality.txt"))
cat(paste0("Variables: ave_s_g_area_abs; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_s_g_area_abs; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_s_g_area_abs; PC1
## Observed MI: 0.194314377140024; pval: 1e-04
## Variables: ave_s_g_area_abs; PC2
## Observed MI: 0.18528553076832; pval: 1e-04
sink()
plot_hist_MI_obs_PC1 <- ggplot(data = data.frame(MI = MI_nullDistr_PC1), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC1, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC1)"))), y = "count",
title = MI_obs_explVar1_title_with_pval) +
annotate('text', x = obs_MI_PC1, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC1
ggsave(filename = sprintf("plot_hist_MI_obs_PC1_neu.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC1,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
plot_hist_MI_obs_PC2 <- ggplot(data = data.frame(MI = MI_nullDistr_PC2), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC2, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC2)"))), y = "count",
title = MI_obs_explVar2_title_with_pval) +
annotate('text', x = obs_MI_PC2, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC2
ggsave(filename = sprintf("plot_hist_MI_obs_PC2_neu.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC2,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
indeptest <- function(model) {
return(Box.test(resid(model)[order(fitted(model))], type = "Ljung-Box"))
}
lmModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netNeuResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netNeuResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0030146 -0.0005346 -0.0000209 0.0004947 0.0045215
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.064e-03 1.501e-05 470.708 <2e-16 ***
## PC1 1.513e-06 6.029e-06 0.251 0.802
## PC2 5.068e-06 8.385e-06 0.604 0.546
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.000822 on 2997 degrees of freedom
## Multiple R-squared: 0.0001429, Adjusted R-squared: -0.0005244
## F-statistic: 0.2141 on 2 and 2997 DF, p-value: 0.8073
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.0001427681 0.0001427681
vif(lmModel)
## PC1 PC2
## 1 1
shapiro.test(lmModel[['residuals']])
##
## Shapiro-Wilk normality test
##
## data: lmModel[["residuals"]]
## W = 0.99032, p-value = 2.138e-13
indeptest(lmModel)
##
## Box-Ljung test
##
## data: resid(model)[order(fitted(model))]
## X-squared = 0.2261, df = 1, p-value = 0.6344
partial_eta_squared(lmModel)
## PC1 PC2
## 2.100026e-05 1.218682e-04
# partial R^2
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- signif(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- signif(partial_R2_PC2, digits = 2)
if(partial_R2m_absInStr_num == 1.5e-06){partial_R2m_absInStr_num = "1.5 x 10^{-6}"}
if(partial_R2m_absOutStr_num == 9.8e-08){partial_R2m_absOutStr_num = "9.8 x 10^{-8}"}
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 2)
if(coef_explVar1 == -2.8e-07){coef_explVar1 = "-2.8 x 10^{-7}"}
if(coef_explVar2 == -1e-07){coef_explVar2 = "-1 x 10^{-7}"}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_constVar_resid <- ggplot(data = data.frame("Fitted_values" = fitted(lmModel),
"Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(x = Fitted_values, y = Pearsons_residuals)) +
geom_point(alpha = 0.2, size = 0.5) +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
annotate("label", x = 0.0070775, y = 0.0015, label = "Neutrality", size = 3) +
labs(x = "Fitted values", y = "Pearson's residuals")
plot_constVar_qqResid <- ggplot(data = data.frame("Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(sample = Pearsons_residuals)) +
stat_qq(alpha = 0.2, size = 0.5) + stat_qq_line() +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
labs(x = "Theoretical quantiles", y = "Sample quantiles",
title = "Normal Q-Q plot, residuals")
plot_constVar_resid
plot_constVar_qqResid
plot_PC1_selpress_neu <- ggplot(netNeuResults, aes(y = ave_s_g_area_abs, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = 0.95, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
ylim(0, 1)
plot_PC1_selpress_neu
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2_selpress_neu <- ggplot(netNeuResults, aes(y = ave_s_g_area_abs, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 0.95, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
scale_x_continuous(n.breaks = 4) +
ylim(0, 1)
plot_PC2_selpress_neu
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_s_g_area_abs,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_s_g_area_abs,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_s_g_area_abs,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_s_g_area_abs,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_s_g_area_abs-PCs.txt"))
cat(paste0("Variables: ave_s_g_area_abs; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_s_g_area_abs; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_s_g_area_abs; PC1
## Observed MI: 0.266973303808035; pval: 1e-04
## Variables: ave_s_g_area_abs; PC2
## Observed MI: 0.25590923039374; pval: 1e-04
sink()
plot_hist_MI_obs_PC1 <- ggplot(data = data.frame(MI = MI_nullDistr_PC1), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC1, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC1)"))), y = "count",
title = MI_obs_explVar1_title_with_pval) +
annotate('text', x = obs_MI_PC1, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC1
ggsave(filename = sprintf("plot_hist_MI_obs_PC1_sel.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC1,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
plot_hist_MI_obs_PC2 <- ggplot(data = data.frame(MI = MI_nullDistr_PC2), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC2, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC2)"))), y = "count",
title = MI_obs_explVar2_title_with_pval) +
annotate('text', x = obs_MI_PC2, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC2
ggsave(filename = sprintf("plot_hist_MI_obs_PC2_sel.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC2,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
indeptest <- function(model) {
return(Box.test(resid(model)[order(fitted(model))], type = "Ljung-Box"))
}
lmModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.68193 -0.03798 0.01123 0.04778 0.14524
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7738156 0.0013968 554.01 <2e-16 ***
## PC1 -0.0074498 0.0005611 -13.28 <2e-16 ***
## PC2 -0.0075850 0.0007804 -9.72 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0765 on 2997 degrees of freedom
## Multiple R-squared: 0.08286, Adjusted R-squared: 0.08225
## F-statistic: 135.4 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.08280831 0.08280831
vif(lmModel)
## PC1 PC2
## 1 1
shapiro.test(lmModel[['residuals']])
##
## Shapiro-Wilk normality test
##
## data: lmModel[["residuals"]]
## W = 0.89765, p-value < 2.2e-16
indeptest(lmModel)
##
## Box-Ljung test
##
## data: resid(model)[order(fitted(model))]
## X-squared = 0.15435, df = 1, p-value = 0.6944
partial_eta_squared(lmModel)
## PC1 PC2
## 0.05555326 0.03056054
# partial R^2
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 1)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 2)
if(coef_explVar2 == -0.0096){coef_explVar2 = -0.009}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
if(pval_explVar1 == 4.9e-11) {pval_coef1_title = paste0("p = 4.9 x 10^{-11}")}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_constVar_resid_sel <- ggplot(data = data.frame("Fitted_values" = fitted(lmModel),
"Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(x = Fitted_values, y = Pearsons_residuals)) +
geom_point(alpha = 0.2, size = 0.5) +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
annotate("label", x = 0.75, y = -0.5, label = "Selection", size = 3) +
labs(x = "Fitted values", y = "Pearson's residuals")
plot_constVar_qqResid_sel <- ggplot(data = data.frame("Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(sample = Pearsons_residuals)) +
stat_qq(alpha = 0.2, size = 0.5) + stat_qq_line() +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
labs(x = "Theoretical quantiles", y = "Sample quantiles",
title = "Normal Q-Q plot, residuals")
plot_constVar_resid_sel
plot_constVar_qqResid_sel
plot_ModelDiagnostics <- plot_grid(plot_constVar_resid_sel, plot_constVar_qqResid_sel,
plot_constVar_resid, plot_constVar_qqResid,
ncol = 2,
labels = "AUTO")
# save to plots folder
ggsave(filename = sprintf("plot_ModelDiagnostics_networkProperties.png"),
path = pathToPlotsFolder,
plot = plot_ModelDiagnostics,
device = "png", scale = 1.2, width = 12, height = 12, units = "cm",
dpi = 300, limitsize = TRUE,
bg = "white")
plot_PC1_selpress_sel <- ggplot(netSelResults, aes(y = ave_s_g_area_abs, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2) +
geom_quantile(quantiles = c(.5), color = "black", size = 0.75) +
geom_quantile(quantiles = c(.25, .75), color = "black", size = 0.5, linetype = 2) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = 0.95, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
ylim(0, 1)
plot_PC1_selpress_sel
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2_selpress_sel <- ggplot(netSelResults, aes(y = ave_s_g_area_abs, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2) +
geom_quantile(quantiles = c(.5), color = "black", size = 0.75) +
geom_quantile(quantiles = c(.25, .75), color = "black", size = 0.5, linetype = 2) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 0.95, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
scale_x_continuous(n.breaks = 4) +
ylim(0, 1)
plot_PC2_selpress_sel
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
jointTitle_sel <- ggdraw() + draw_label("Selection",
size = 20,
fontface = 'bold')
jointTitle_neu <- ggdraw() + draw_label("Neutrality",
size = 20,
fontface = 'bold')
jointTitle_combined <- cowplot::plot_grid(NULL, jointTitle_sel, NULL,
NULL, jointTitle_neu, NULL,
labels = c("", "", "", "", "", ""),
ncol = 6,
rel_widths = c(0.5, 1, 0.5, 0.5, 1, 0.5))
plot_netPropertiesFigure_body <- ggpubr::ggarrange(plot_PC1_selpress_sel, plot_PC2_selpress_sel,
plot_PC1_selpress_neu, plot_PC2_selpress_neu,
labels = "AUTO", font.label = list(size = 20, face = "bold"),
ncol = 4, nrow = 1,
common.legend = TRUE, legend = "bottom")
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_netPropertiesFigure <- cowplot::plot_grid(jointTitle_combined,
plot_netPropertiesFigure_body,
ncol = 1,
rel_heights = c(0.1, 1))
ggsave(filename = sprintf("plot_netPropertiesFigure.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2.1, height = 800, width = 2250, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2.1, height = 900, width = 2250, units = "px",
dpi = 300, limitsize = TRUE)
sessionInfo()
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.5 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] dplyr_1.0.7 rstatix_0.7.0 FSA_0.9.3 factoextra_1.0.7
## [5] ade4_1.7-15 corrplot_0.90 Hmisc_4.3-1 Formula_1.2-3
## [9] survival_3.2-7 lattice_0.20-38 reshape2_1.4.3 latex2exp_0.4.0
## [13] RColorBrewer_1.1-2 car_3.0-11 carData_3.0-4 lme4_1.1-27.1
## [17] Matrix_1.2-18 infotheo_1.2.0 cowplot_1.1.1 gridExtra_2.3
## [21] ggridges_0.5.2 ggpubr_0.4.0 ggplot2_3.3.5 MuMIn_1.43.17
## [25] nlme_3.1-144 rmarkdown_2.10
##
## loaded via a namespace (and not attached):
## [1] matrixStats_0.60.0 tools_3.6.3 backports_1.2.1
## [4] bslib_0.2.5.1 utf8_1.2.2 R6_2.5.1
## [7] rpart_4.1-15 DBI_1.1.0 colorspace_2.0-2
## [10] nnet_7.3-12 withr_2.4.2 tidyselect_1.1.1
## [13] curl_4.3.2 compiler_3.6.3 quantreg_5.86
## [16] htmlTable_1.13.3 SparseM_1.81 labeling_0.4.2
## [19] sass_0.4.0 scales_1.1.1 checkmate_2.0.0
## [22] stringr_1.4.0 digest_0.6.28 foreign_0.8-75
## [25] minqa_1.2.4 rio_0.5.27 base64enc_0.1-3
## [28] jpeg_0.1-8.1 pkgconfig_2.0.3 htmltools_0.5.2
## [31] dunn.test_1.3.5 highr_0.9 fastmap_1.1.0
## [34] htmlwidgets_1.5.3 rlang_0.4.12 readxl_1.3.1
## [37] rstudioapi_0.13 farver_2.1.0 jquerylib_0.1.4
## [40] generics_0.1.0 jsonlite_1.7.2 acepack_1.4.1
## [43] zip_2.2.0 magrittr_2.0.1 Rcpp_1.0.7
## [46] munsell_0.5.0 fansi_0.5.0 abind_1.4-5
## [49] lifecycle_1.0.1 stringi_1.7.3 yaml_2.2.1
## [52] MASS_7.3-57 plyr_1.8.6 grid_3.6.3
## [55] ggrepel_0.9.1 forcats_0.5.1 crayon_1.4.2
## [58] haven_2.4.3 splines_3.6.3 hms_1.1.0
## [61] knitr_1.33 pillar_1.6.4 boot_1.3-25
## [64] ggsignif_0.6.2 stats4_3.6.3 glue_1.5.0
## [67] evaluate_0.14 latticeExtra_0.6-29 data.table_1.14.0
## [70] vctrs_0.3.8 png_0.1-7 nloptr_1.2.2.2
## [73] MatrixModels_0.5-0 cellranger_1.1.0 gtable_0.3.0
## [76] purrr_0.3.4 tidyr_1.1.3 xfun_0.25
## [79] openxlsx_4.2.4 broom_0.7.9 conquer_1.0.2
## [82] tibble_3.1.6 cluster_2.1.0 ellipsis_0.3.2
packageVersion('igraph')
## [1] '1.2.4.2'
packageVersion('intergraph')
## [1] '2.0.2'
packageVersion('lme4')
## [1] '1.1.27.1'
packageVersion('nlme')
## [1] '3.1.144'
packageVersion('MuMIn')
## [1] '1.43.17'
packageVersion('infotheo')
## [1] '1.2.0'
packageVersion('car')
## [1] '3.0.11'
packageVersion('ade4')
## [1] '1.7.15'